<template>
  <div>
    <el-card class="box-card">
      <div slot="header" class="clearfix" style="height: 32px">
        <el-row align="middle" type="flex">
          <el-col>
            <span>{{ "评估内容" }}</span> &nbsp;&nbsp;
            <span>{{ title }}</span>
          </el-col>
          <el-col style="text-align: right">
            <el-tag type="warning" v-if="item['clazzId']">{{ score }}</el-tag>
            <el-tag v-if="item['clazzId']">本学年评语</el-tag>
          </el-col>
        </el-row>
      </div>
      <div>
        <el-table
          :height="tableHeight"
          :max-height="tableHeight"
          :data="tableData"
          border
          row-key="id"
          :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
          style="width: 100% ">
          <el-table-column
            prop="name"
            label="评估项目">
          </el-table-column>
          <el-table-column
            prop="hasScore"
            align="center"
            label="得分">
          </el-table-column>
          <el-table-column
            align="center"
            label="操作">
            <template slot-scope="{ row }">
              <el-link type="primary" v-if="row.pid" @click="detailEval(row)">详情</el-link>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </el-card>
  </div>
</template>

<script>
import {CardList} from '@/api/bt/student-eval/check/eval-content'

export default {
  name: "EvalContent",
  data() {
    let item = {}
    return {
      item,
      //表格高度根据窗口
      tableHeight: window.innerHeight - 220,
      screenHeight: window.innerHeight,
      // 表格数据
      tableData: [],
      //标题
      title: undefined,
      //分数
      score: undefined,
    }
  },
  mounted() {
    const that = this
    window.onresize = () => {
      return (() => {
        window.screenHeight = window.innerHeight
        this.screenHeight = window.screenHeight;
      })()
    }
  },
  watch: {
    screenHeight(val) {
      this.screenHeight = val
      this.tableHeight = this.screenHeight - 220
    }
  },
  methods: {
    //页面初始化函数
    init(verId, clazzId) {
      this.getCardList(verId, clazzId)
    },
    //获取card信息 方法
    getCardList(verId, clazzId) {
      CardList(verId, clazzId).then((res) => {
        this.item = res.data;
        this.title = res.data['clazzId'] + "/" + res.data['gradeName']
        this.score = res.data['hasScore'] + "分"
        this.tableData = res.data.items
      })
    },
    detailEval(row) {
      this.$emit("item-detail", row, this.item['clazzId'])
    },
  },
}
</script>

<style scoped>
::v-deep.el-table--border {
  border-bottom: 1px solid #EBEEF5;
}
</style>
